# 路由配置
from django.urls import path
from . import views
from .routes import routes

from rest_framework import permissions
from drf_yasg.views import get_schema_view
from drf_yasg import openapi
from django.conf.urls import url

schema_view = get_schema_view(
    openapi.Info(
        title="晴天生鲜接口文档",
        default_version='v1',
        # description="django + mysql",
        # terms_of_service="https://www.google.com/policies/terms/",
        # contact=openapi.Contact(email="contact@dummy.local"),
        # license=openapi.License(name="BSD License"),
    ),
    public=True,
    permission_classes=(permissions.AllowAny,),
)


route_list = []
for item in routes:
    route_list += item
all_routes = []
for item in route_list:
    all_routes.append(path(item[1], item[3]))  

urlpatterns = [
    *all_routes,
    url(r'^docs/', schema_view.with_ui('swagger',
        cache_timeout=0), name='schema-swagger-ui'),
    url(r'^rdocs/', schema_view.with_ui('redoc',
        cache_timeout=0), name='schema-redoc'),

    path('', views.home_view),
    path('home', views.home) 
]
